package com.naivesoft.lottery.util;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class RandomBalls {
	public static final List<Integer> getRandomBalls(int maxBalls, int randomBallCount) {
		Random rand = new Random();
		List<Integer> results = new ArrayList<Integer>();
		
		for (int i = 0; i < randomBallCount; i++) {
			int ball = rand.nextInt(maxBalls) + 1;
			if (results.contains(Integer.valueOf(ball))) {
				i--;
			} else {
				results.add(Integer.valueOf(ball));
			}
		}
		return results;
	}
}
